package ynu.czs.controller;

import ynu.czs.pojo.Cart;
import ynu.czs.pojo.Result;
import ynu.czs.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/cart")
public class CartController {
    @Autowired
    private CartService cartService;

    @PostMapping()
    public Result addCart(@RequestBody Cart cart){
        cartService.addCart(cart);
        return Result.success();
    }

    @PutMapping("/addQuantity/{cartId}")
    public Result addQuantity(@PathVariable("cartId") Integer cartId){
        cartService.addQuantity(cartId);
        return Result.success();
    }

    @PutMapping("/substrateQuantity/{cartId}")
    public Result substrateQuantity(@PathVariable("cartId") Integer cartId){
        cartService.substrateQuantity(cartId);
        return Result.success();
    }
}
